<template>
  <div>
    <div style="text-align:left">
      患者信息：
      <el-tag>姓名：{{patient.real_name}}</el-tag>
      <el-tag>病历号：{{patient.case_number}}</el-tag>
      <el-tag>年龄：{{patient.age}}</el-tag>
      <el-tag>性别：{{patient.gender}}</el-tag>
    </div>
    <el-divider></el-divider>
    <div style="font-size:20px;text-align:left">
      <i class="el-icon-document-checked">门诊确诊</i>
    </div>
    <el-divider></el-divider>
    <el-descriptions title="确诊信息录入：" :column="1" border style="width:80%">
      <el-descriptions-item label="诊断结果：" :labelStyle="{'width':'120px'}">
        <el-input type="textarea" :auto-size="{minRows:2,maxRows:4}" v-model="patientDiagnosis.diagnosis" placeholder="输入诊断结果判断"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="处理意见：" :labelStyle="{'width':'120px'}">
        <el-input type="textarea" :auto-size="{minRows:2,maxRows:4}" v-model="patientDiagnosis.cure" placeholder="输入治疗意见"></el-input>
      </el-descriptions-item>
    </el-descriptions>
    <el-divider></el-divider>
    <div style="text-align:left">
      <el-button type="primary" @click="updatePatientDiagnosis()">确诊提交</el-button> 
      <el-button type="primary" @click="clearPatientDiagnosis()">重置输入</el-button> 
    </div>
  </div>
</template>
<script>
import qs from 'qs'

export default {
  methods:{
    //确诊提交
    updatePatientDiagnosis(){
      this.patientDiagnosis.register_id = this.patient.id;
      this.$http.post("http://localhost:8092/outpatientDiagnosis",qs.stringify(this.patientDiagnosis)).then(
        (resp)=>{
          this.$message({
            message:resp.data.msg,
            type:"success"
          });
          this.clearPatientDiagnosis();
        }
      )
    },
    //重置输入
    clearPatientDiagnosis(){
      this.patientDiagnosis.diagnosis = "";
      this.patientDiagnosis.cure = "";
    }
  },
  data(){
    return{
      patientDiagnosis:{
        register_id:'',
        diagnosis:'',
        cure:''
      },//提交确诊信息
      patient:{} //患者信息
    }    
  },
  mounted:function() {
    this.patient = JSON.parse(sessionStorage.getItem("record_now_patient"));
    if(isNullMessage(this,this.patient,'请先选择患者')){
      this.patient={
        real_name:'',
        case_number:'',
        age:'',
        gender:''
      }
    }
  },
}
</script>